
import React, { Component } from 'react';
import { connect } from 'dva';
import { Link, routerRedux } from 'dva/router';
import {
    Flex,
    Icon,
} from 'antd-mobile';
import usedsvg from "../../assets/img/used.svg";
import Expiredsvg from "../../assets/img/Expired.svg";

class CouponListItem extends Component {

    render() {
        const {dataItem,finishorder, dispatch} = this.props;
        return  <div style={{
            backgroundColor: "#fff",
            width: "95%",
            margin: ".2rem auto",
            borderRadius: ".1rem"
        }} >

            <div className={dataItem.isUser==0?"useCoupon1":"useCoupon2"} >
                <div style={{marginLeft:".3rem",marginBottom:".1rem"}}>{dataItem.shopActivityPromotionRule.shopActivityEntity.storeName}</div>
                <Flex justify="around">
                    <div style={{fontSize: ".3rem",width:"1.8rem" , textAlign:"right"}}>
                                                    <span style={{fontSize: ".7rem"}}>
                                                        {dataItem.shopActivityPromotionRule.couponSource}
                                                    </span>元
                    </div>
                    <div style={{marginLeft: ".2rem",fontSize: ".28rem",lineHeight:"2.5"}}>
                        <div>
                            {dataItem.shopActivityPromotionRule.description}
                        </div>
                        <div>{dataItem.shopActivityPromotionRule.shopActivityEntity.startTimeStr+"-"+dataItem.shopActivityPromotionRule.shopActivityEntity.endTimeStr}</div>
                    </div>
                    {dataItem.isUser==0?<div style={{
                        backgroundColor: "#fff",
                        color: "#ff0036",
                        padding: ".1rem .35rem",
                        borderRadius: ".45rem"
                    }} onClick={() => this.props.dispatch(routerRedux.push({pathname: `/storesShow/${dataItem.storeId}`}))}
                    >立即使用
                    </div>:""}
                    {dataItem.isUser==1? <Icon type={usedsvg.id} className="shiyong"></Icon>:""}
                    {dataItem.isUser==2? <Icon type={Expiredsvg.id} className="shiyong"></Icon>:""}

                </Flex>

            </div>
            <div style={{padding: ".3rem .5rem"}}>

                <span>会员限制：{dataItem.memberLimitWhere}；</span>
                <span>商品限制：{dataItem.shopActivityPromotionRule.shopActivityEntity.goodsType == 0 ? "全部商品" : dataItem.shopActivityPromotionRule.shopActivityEntity.goodsType == 1 ? "指定商品分类" :dataItem.shopActivityPromotionRule.shopActivityEntity.goodsType == 2 ? "指定商品类型": dataItem.shopActivityPromotionRule.shopActivityEntity.goodsType==3 ? "指定品牌" : '指定商品'}</span>
            </div>
        </div>
    }
}

export default connect(({ couponList }) => ({ couponList }))(CouponListItem);